
/**
 * @function: do register
 *
 */

function do_register() {
    var name = $('input[name="name"]').val() ;
    var pwd = $('input[name="pwd"]').val() ;
    $('.register-msg').html("") ;
    if (name.trim() == '' || name == null || pwd.trim() == '' || pwd == null) {
        $('.register-msg').css("color", "red").html("输入或或密码为空") ;
        return false ;
    }
    var inst = [] ;
    $('input[name="inst"]:checked').each(function() {
        inst.push($(this).val()) ;
    }) ;
    var formValues = {
        'name':name ,
        "pwd":pwd,
        "inst":inst,
        "action":"register"
    } ;
    console.log(formValues) ;
    $.ajax({
        url:'/01_jspBasics/test/ajax',
        type:'POST',
        datatype:'json',
        data:JSON.stringify(formValues),
        success:function(res) {
            console.log(res) ;
            $('.register-msg').css("color", "red").html(res.result) ;
        },
        error: function() {
            console.log("failed") ;
        }
    })
}